4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
19 using System
.Diagnostics
;
21 static internal class Debug
{
23 [Conditional("ASSERTION")]
24 public static void Assert(bool condition
){
26 throw new AssertException("Assertion fired");
29 [Conditional("ASSERTION")]
30 public static void Assert(bool condition
, String message
){
32 throw new AssertException(message
);
35 [Conditional("ASSERTION")]
36 public static void NotImplemented(String message
){
37 throw new AssertException("Method Not Yet Implemented");
40 [Conditional("ASSERTION")]
41 public static void PostCondition(bool condition
){
43 throw new PostConditionException("PostCondition missed");
46 [Conditional("ASSERTION")]
47 public static void PostCondition(bool condition
, String message
){
49 throw new PostConditionException(message
);
52 [Conditional("ASSERTION")]
53 public static void PreCondition(bool condition
){
55 throw new PreConditionException("PreCondition missed");
58 [Conditional("ASSERTION")]
59 public static void PreCondition(bool condition
, String message
){
61 throw new PreConditionException(message
);
64 [Conditional("LOGGING")]
65 public static void Print(String str
){
66 ScriptStream
.Out
.WriteLine(str
);
69 [Conditional("LOGGING")]
70 internal static void PrintLine(String message
) {
71 ScriptStream
.Out
.WriteLine(message
);
74 [Conditional("LOGGING")]
75 public static void PrintStack(){
76 ScriptStream
.PrintStackTrace();
79 [Conditional("LOGGING")]
80 public static void PrintStack(Exception e
){
81 ScriptStream
.PrintStackTrace(e
);
86 internal class AssertException
: Exception
{
87 internal AssertException(String message
)
92 internal class PreConditionException
: AssertException
{
93 internal PreConditionException(String message
)
98 internal class PostConditionException
: AssertException
{
99 internal PostConditionException(String message
)